﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace FieldTemplate
{
    public class FieldSetVmBase : INotifyPropertyChanged
    {
        private string _FieldName;
        public string FieldName
        {
            get
            {
                return _FieldName;
            }
            set
            {
                _FieldName = value;
                RaisePropertyChanged("FieldName");
            }
        }

        private string _FieldType;
        public string FieldType
        {
            get
            {
                return _FieldType;
            }
            set
            {
                _FieldType = value;
                RaisePropertyChanged("FieldType");
            }
        }


        public virtual string GetFieldValue()
        {
            return "";
        }

        private UserControl _SetPanel;


        public event PropertyChangedEventHandler PropertyChanged;

        public UserControl SetPanel
        {
            get
            {
                return _SetPanel;
            }
            set
            {
                _SetPanel = value;
                RaisePropertyChanged("SetPanel");
            }
        }

        protected void RaisePropertyChanged(string name)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }


        public virtual Fieldinfo Serialize()
        {
            Fieldinfo ret = new Fieldinfo();
            ret.FieldName = FieldName;
            ret.FieldType = FieldType;
            

            List<Propertyinfo> propertyinfos = new List<Propertyinfo>();

            propertyinfos.Add(new Propertyinfo() { PorpertyName = "FieldName", PropertyType = "string", PropertyValue = FieldName });
            propertyinfos.Add(new Propertyinfo() { PorpertyName = "FieldType", PropertyType = "string", PropertyValue = FieldType });

            ret.propertyinfos = propertyinfos;
            return ret;
        }

    }


    [Serializable]
    public class Fieldinfo
    {
        public string FieldName;//学号
        public string FieldType;//学号
        public List<Propertyinfo> propertyinfos;
    }

    [Serializable]
    public class Propertyinfo
    {
        public string PorpertyName; //FieldName

        public string PropertyType; // int   string bool double 

        public string PropertyValue;//学号
    }


}
